class Listener:

    def __init__(self, player, abilityIRPM, abilityModifier, abilityAffecters, otherPlayers=False):
        self.player = player
        self.abilityIRPM = abilityIRPM
        self.abilityModifier = abilityModifier
        self.abilityAffecters = abilityAffecters
        self.otherPlayers = otherPlayers
        
    def getPlayer():
        return self.player
        
    def affectsOtherPlayers():
        return self.otherPlayers
        
    def trigger(self, tile):
        tileColor = tile.getColor()
        tileType = tile.getType()
        if (('R' in self.abilityModifier and tileColor == 'green') or
            ('G' in self.abilityModifier and tileColor == 'grey') or
            ('C' in self.abilityModifier and tileColor == 'blue') or
            ('I' in self.abilityModifier and tileColor == 'yellow') or
            ('A' in self.abilityModifier and tileType == 'AIRPORT') or
            ('E' in self.abilityModifier and tileType == 'RESTAURANT') or
            ('O' in self.abilityModifier and tileType == 'OFFICE') or
            ('S' in self.abilityModifier and tileType == 'SCHOOL') or
            ('K' in self.abilityModifier and tileType == 'SKYSCRAPER') or
            ('D' in self.abilityModifier and tileType == 'CAR DEALERSHIP')):
           
            if (self.abilityIRPM == 'I'):
                self.player.addIncome(self.abilityAffecters)
            elif (self.abilityIRPM == 'R'):
                self.player.addReputation(self.abilityAffecters)
            elif (self.abilityIRPM == 'P'):
                self.player.addPopulation(self.abilityAffecters)
            elif (self.abilityIRPM == 'M'):
                self.player.addMoney(self.abilityAffecters)  
                
            print self.abilityAffecters, "added to", self.player.getName() + "'s", self.abilityIRPM, "by", tile.getName(), "(via listener)"
            
    